<template>
  <div class="order-item">
    <div class="order-title">
      <span class="cinema-name line-ellipsis">{{ order.cinema.name }}</span>
      <span class="right">{{ order.orderStatus }}</span>
    </div>
    <router-link :to="`/OrderDetail/${order.orderId}`">
      <div class="order-detail-info">
        <div class="order-info">
          <img :src="order.movie.img | imgfmt(57, 80)" alt="" />
          <div class="order-desc">
            <div class="movie-name">
              <span>{{ order.movie.name }} {{ order.count }}张</span>
            </div>
            <div class="ff-tag-empty"></div>
            <div class="showTime line-ellipsis">
              {{ startDateFmt(order.show.startTime) }}
            </div>
            <div class="position line-ellipsis">
              {{ order.seat.hallName }}
              <!-- {{ seatListStr(order.seat.list) }} -->
            </div>
          </div>
        </div>
      </div>
    </router-link>
    <div class="order-more border-1px-t">
      <div class="price">总价：{{ order.price }}元</div>
      <span class="right"
        ><span class="bottom-btn" @click="handleDelOrder(order.orderId)"
          >删除订单</span
        ></span
      >
    </div>
  </div>
</template>

<script>
import { delOrder } from "@/api/cart"
export default {
  props: ["order", "delOrder"],
  created() {
    console.log(this.order)
  },
  methods: {
    startDateFmt(start) {
      const date = new Date(start)
      return `${date.getFullYear()}年${
        date.getMonth() + 1
      }月${date.getDate()}日 ${date.getHours()}:${date.getMinutes()}`
    },
    seatListStr(list) {
      let str = ""
      list.forEach((seat) => {
        str += ` ${seat.rowId}排${seat.columnId}座`
      })
      return str
    },
    handleDelOrder(orderId) {
      delOrder(orderId)
      this.delOrder(orderId)
    }
  }
}
</script>

<style lang="scss" scoped>
.line-ellipsis {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.order-item {
  margin-bottom: 10px;
  background-color: #ffffff;
  color: #777;
  font-size: 14px;
  padding: 0 15px;
  .order-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 38px;
    .cinema-name {
      width: 300px;
    }
  }
  .order-detail-info {
    height: 82px;
    padding: 13px 0;
    border-top: 1px solid #f7f7f7;
    .order-info {
      display: flex;
      .order-desc {
        margin-left: 14px;
        .movie-name {
          margin-bottom: 5px;
          height: 22px;
          line-height: 22px;
          font-weight: 500;
          font-size: 16px;
          color: #000;
        }
        .ff-tag-empty {
          height: 14px;
          margin: 0;
        }
        .showTime,
        .position {
          font-size: 12px;
          color: #888;
          line-height: 18px;
          height: 18px;
        }
        .showTime {
          font-weight: 700;
          margin-bottom: 2px;
        }
      }
    }
  }
  .order-more {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 37px;
    border-top: 1px solid #f7f7f7;
    .bottom-btn {
      display: inline-block;
      border: 1px solid #ccc;
      border-radius: 12px;
      font-size: 12px;
      height: 24px;
      line-height: 24px;
      color: #999;
      padding: 0 10px;
    }
  }
}
</style>
